package com.weimob.mcloud.wechatwork.customer.mq.handler.group;

import com.weimob.mcloud.wechatwork.customer.domain.ExternalUserChangeInfo;
import com.weimob.mcloud.wechatwork.customer.mq.dto.CorpChatGroupDTO;
import com.weimob.mcloud.wechatwork.customer.mq.handler.externaluser.CorpExternalUserHandler;
import com.weimob.mcloud.wechatwork.customer.mq.model.CorpChatGroupServiceImpl;
import com.weimob.soa.common.response.SoaResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author yuzhaoyang
 * @desc 客户群变更事件处理器
 * @date 2021-02-07 00:31
 */
@Service
@Slf4j
public class UpdateGroupChatHandler implements CorpExternalUserHandler {

    @Autowired
    private CorpChatGroupServiceImpl corpChatGroupService;

    @Override
    public SoaResponse<?, ?> handleCorpExternalUser(ExternalUserChangeInfo externalUserChangeInfo) {
        CorpChatGroupDTO dto = new CorpChatGroupDTO();
        ChatGroupConverter.convert2CorpChatGroupDTO(externalUserChangeInfo, dto);
        return corpChatGroupService.update(dto, null);
    }
}
